<?php
$width = array('left' => 850,'right'=>150);
if (in_array($action, array('audit'))) {
  $width = array('left' => 800,'right'=>200);
}
?>
<div class="panel panel-default">
  <!-- Default panel contents -->
  <div class="panel-heading">营销活动结算申请</div>
  <div class="panel-body mb27">
  <div style="<?php if (in_array($action, array('edit','audit'))) {?>width: <?=$width['left']?>px; float: left;<?php }?>" class="table-responsive">
  <table class="table table-bordered" style="width: 2400px; white-space: nowrap;">
    <thead>
      <tr>
        <th class="bg-primary text-center">流水号</th>
        <th class="bg-primary text-center">项目名称</th>
        <th class="bg-primary text-center">项目补贴上限额度</th>
        <th class="bg-primary text-center">活动类型</th>
        <th class="bg-primary text-center">活动主题</th>
        <th class="bg-primary text-center">活动地点</th>
        <th class="bg-primary text-center">开始时间</th>
        <th class="bg-primary text-center">结束时间</th>
        <th class="bg-primary text-center" colspan="2">活动目标</th>
        <th class="bg-primary text-center" colspan="2">实际达成</th>
        <th class="bg-primary text-center" colspan="2">活动目标达成率</th>
        <th class="bg-primary text-center">结算申请费用</th>
        <th class="bg-primary text-center">结算材料</th>
        <!-- <th class="bg-primary text-center">结算相片</th> -->
        <th class="bg-primary text-center">预算审核费用</th>
        <th class="bg-primary text-center">审核情况</th>
        <th class="bg-primary text-center">结算审核费用</th>
        <th class="bg-primary text-center">评分系数</th>
        <th class="bg-primary text-center">项目补贴可结算额度</th>
        <th class="bg-primary text-center">备注</th>
      </tr>
    </thead>
    <tbody>
    <?php foreach($offlineList as $k => $v): ?>
      <tr style="line-height:34px;">
        <td class="text-center"><?php echo $v['id'] ?></td>
        <td class="text-center"><?php echo $v['projectName'] ?></td>
        <td class="text-center"><?php echo $v['upperLimitMoney'] ?></td>
        <td class="text-center"><?php echo $v['mediaTypeStr'] ?></td>
        <td class="text-center"><?php echo $v['theme'] ?></td>
        <td class="text-center"><?php echo $v['address'] ?></td>
        <td class="text-center"><?php echo $v['startTime'] ?></td>
        <td class="text-center"><?php echo $v['endTime'] ?></td>
        <td class="text-center">集客目标：<?php echo $v['targetCustomer'] ?></td>
        <td class="text-center">订单目标<?php echo $v['targetOrder'] ?></td>
        <td class="text-center">集客效果：<?php echo $v['actualCustomer'] ?></td>
        <td class="text-center">订单效果<?php echo $v['actualOrder'] ?></td>
        <td class="text-center">集客目标达成率：<?php echo (float)$v['rateCustomer'] ? $v['rateCustomer']  : 0 ?>%</td>
        <td class="text-center">订单目标达成率:<?php echo (float)$v['rateOrder'] ? $v['rateOrder'] : 0 ?>%</td>
        <td class="text-center"><?php echo $v['settleApply'] ?></td>
        <td class="text-center">
          <?php if ($v['settleFileId']) {?>
            <a type="button" class="btn btn-default" href="<?=printUrl('Upload','download',array('fileId'=>$v['settleFileId']))?>" aria-label="Left Align" role="button">
              <span class="glyphicon glyphicon-download-alt" aria-hidden="true"></span>
              附件下载
            </a>
            <?php } ?>
        </td>
        <!-- <td class="text-center">
          <?php if ($v['voucher']): ?>
          <a class="btn btn-default" onclick="newWindow('广宣传播凭证查看','<?=printUrl('CommonOffline','voucherCheck', array('id'=>$v['id']))?>',800,600)" role="button">查看</a>
          <?php endif ?>
        </td> -->
        <td class="text-center"><?php echo $v['budgetAudit'] ?></td>
        <td class="text-center"><?php echo $v['settleAuditStr'] ?></td>
        <td class="text-center"><?php echo $v['lastSettleAudit'] ?></td>
        <td class="text-center"><?php echo $v['kpi'] ?></td>
        <td class="text-center"><?php echo $v['canSettleMoney'] ?></td>
        <td class="text-center"><?php echo $v['remarks'] ?></td>
      </tr>
    <?php endforeach; ?>
    </tbody>
  </table>
  </div>
  <?php if (in_array($action, array('edit','audit'))) {?>
  <div style="width: <?=$width['right']?>px; float: right;">
    <table class="table table-bordered">
    <thead>
      <tr>
        <?php if (in_array($action, array('audit'))) {?>
        <th class="bg-primary text-center">评分系数</th>
        <th class="bg-primary text-center">审核结果</th>
        <?php } ?>
        <th class="bg-primary text-center">操作</th>
        </tr>
    </thead>
    <tbody>
      <?php foreach($offlineList as $k => $v): ?>
      <tr>
        <?php if (in_array($action, array('edit'))) {?>
          <td class="text-center">
            <!-- 没有预算审核，以结算审核为判断基准 -->
            <?php if (in_array($v['settleAuditRs'], array(-1,0,3) )) {?>
            <a class="btn btn-default" onclick="newWindow('营销活动结算申请','<?=printUrl('CommonOffline','settleEdit', array('id'=>$v['id']))?>',900,600)" role="button">结算</a>
            <?php }else{echo '&nbsp;';}  ?>
          </td>
          <?php } ?>
          <?php if (in_array($action, array('audit'))) {?>
          <td class="text-center">
            <?php
            $options = $this->userLib->getSettleKpiOptions();
            $extra = ' id="offlineSettleKpi_'.$v['id'].'" class="form-control" style="width:50px;"';
            if ($this->user['userRole'] < $v['settleAuditRole']) {
              $extra .= " disabled";
            }
            echo form_dropdown('offline['.$v['id'].'][kpi]', $options, $v['kpi'], $extra);
            ?>
          </td>
          <td class="text-center">
            <?php
            $options = $this->userLib->getSettleAuditOptions();
            $extra = ' id="offlineSettleAuditRs_'.$v['id'].'" class="form-control settleAuditRs" style="width:70px;" money="'.((float)$v['settleAudit'] ? $v['settleAudit'] : $v['settleApply']).'" ';
            if ($this->user['userRole'] < $v['settleAuditRole']) {
              $extra .= " disabled";
            }
            echo form_dropdown('offline['.$v['id'].'][settleAuditRs]', $options, $v['settleAuditRs'], $extra);
            ?>
          </td>
          <td>
            <button class="btn btn-default btn-danger" style="width: 50px;" type="button" onclick="ajaxConfirmSubmit('你确定提交审核么？','<?=printUrl('CommonSettle','adminAudit')?>',{procId:<?=$v['procId']?>,offline:{<?=$v['id']?>:{kpi:$('#offlineSettleKpi_<?=$v['id']?>').val(),settleAuditRs:$('#offlineSettleAuditRs_<?=$v['id']?>').val()}}})">审核</button>
          </td>
          <?php } ?>
        </tr>
        <?php endforeach; ?>
    </tbody>
    </table>
  </div>
  <?php } ?>
  </div>
</div>